package com.unittec.zk.provider.auth.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.unittec.zk.provider.auth.entity.SysDepart;

import lombok.Data;

/**
 * @description 部门id
 * @author Jason
 * @date 2019/11/07
 */
@Data
public class DepartId implements Serializable {

    private static final long serialVersionUID = 1L;
    List<DepartId> children = new ArrayList<DepartId>();
    /**
     * 主键ID
     */
    private String key;
    /**
     * 主键ID
     */
    private String value;
    /**
     * 部门名称
     */
    private String title;

    /**
     * 将SysDepartTree的部分数据放在该对象当中
     * 
     * @param tree
     * @return
     */
    public DepartId convert(SysDepartTree tree) {
        this.key = tree.getId();
        this.value = tree.getId();
        this.title = tree.getDepartName();
        return this;
    }

    /**
     * 该方法为用户部门的实现类所使用
     * 
     * @param sysDepart
     * @return
     */
    public DepartId convertByUserDepart(SysDepart sysDepart) {
        this.key = sysDepart.getId();
        this.value = sysDepart.getId();
        this.title = sysDepart.getDepartName();
        return this;
    }

}
